/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.bopet.jocadv.core;

import java.io.Serializable;

/**
 *
 * This abstract class represents elements
 *
 * @author bocskapeter
 */
public abstract class Element implements Serializable {

    // first element id
    private static long ID = 0;
    // unique element id
    private final long id;
    // name of the element
    private String name;
    // status of the element
    private int status;
    
    /**
     * tolerance below which points are considered identical
     */
    public static final double TOLEARANCE = 0.000000001;

    /**
     * Generates a new id
     *
     * @return new id as long
     */
    public static long getNewID() {
        return ID++;
    }

    /**
     * Gives the id of the element
     *
     * @return id of the element as long
     */
    public long getId() {
        return id;
    }

    /**    
     * Gives the name of the element
     *
     * @return name of the element as String
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the name of the element
     *
     * @param name String
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Gives the status of the element
     *
     * @return status of the element as int
     */
    public int getStatus() {
        return status;
    }

    /**
     * Sets the status of the element
     *
     * @param status int
     */
    public void setStatus(int status) {
        this.status = status;
    }

    /**
     * Default constructor, builds a new element with new id and with the given
     * name
     *
     * @param name String
     */
    public Element(String name) {
        this.id = Element.getNewID();
        this.name = name + this.id;
        this.status = 0;
    }

    /**
     * Converts the element to String
     *
     * @return the element as String
     */
    @Override
    public String toString() {
        return "Element{" + "id=" + id + ", name=" + name + ", status=" + status + '}';
    }

}
